import { ParamsData } from '@/model/order/AllOrder'

/**
 * @description: 创建options选项
 * @param {Array} list
 * @param {string} props
 * @return {*}
 */
export const createOptions = (list: Array<string>, props?: string) => {
  const propName = props || 'value'
  return list.map((item: string, index: number): object => {
    return { label: item, [propName]: index++ }
  })
}
/**
 * @description: 筛选get请求参数不存在0的情况
 * @param {Array} keys
 * @param {ParamsData} params
 * @return {*}
 */
export const filterParams = (keys: Array<string>, params: ParamsData): ParamsData => {
  const result = Object.assign({}, params)
  keys.forEach((key: string) => {
    if (!result[key]) delete result[key]
  })
  return result
}
